package cm.tl.pms.common.entity;


/**
 * message
 *
 * @Auther: lwp
 * @Date: 2022/10/19 - 10 - 19 - 16:47
 * @Description
 * @version: 1.0
 */
public enum MessageEnum implements ConverterBaseEnum {

    LOGIN_SUCCESS("100_11_01", "登录成功!"),
    LOGIN_FALSE("100_11_02", "用户名或密码不正确!"),
    QUIT("100_11_03", "退出成功!"),
    QUIT_FALSE("100_11_04", "用户未登录!"),


    ORDER_SUCCESS("200_01_01", "下单成功!"),


    ;

    /**
     * 状态码
     */
    private String code;
    /**
     * 返回信息
     */
    private String msg;

    MessageEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static String getErrorNo(String code) {
        for (MessageEnum campTypeEnum : values()) {
            if (campTypeEnum.code.equals(code)) {
                return campTypeEnum.msg;
            }
        }
        return null;
    }

    public static String getErrorName(String eventNo) {
        MessageEnum[] values = values();
        for (MessageEnum campTypeEnum : values) {
            if (campTypeEnum.msg.equals(eventNo)) {
                return campTypeEnum.code;
            }
        }
        return null;
    }

    @Override
    public String toViewValue() {
        return code;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
